package com.dl.study.config.jwt;

import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

/**
 * @Author: user
 * @Date: 2021/10/25 10:34
 * @Description:
 */
public class ShiroKit {

    public final static String hashAlgorithmName = "MD5";

    //循环次数
    public final static int hashIterations = 1024;


    //盐值
    public final static String salt = "web_salt";

    /**
     * shiro密码加密工具类
     *
     * @param credentials 密码
     * @param saltSource  密码盐
     * @return
     */
    public static String md5(String credentials, String saltSource) {
        ByteSource salt = new Md5Hash(saltSource);
        return new SimpleHash(hashAlgorithmName, credentials, salt, hashIterations).toString();
    }

    public static void main(String[] args) {
        System.out.println(md5("sx1234", "123456"));
    }
}
